package mini.reanimate;

import owg.util.Calc;
import audio.Audio;
import audio.Clip;
import hubol.Entity;

public class Spam extends Entity{
	private final Clip sound;
	private int strikes;
	private int timer;
	private final int wait;
	
	public Spam(String sound, int strikes) {
		this(sound, strikes, 9);
	}

	public Spam(String sound, int strikes, int wait) {
		super(0, 0);
		this.sound = Audio.getClip(sound);
		this.strikes = strikes;
		this.wait = wait;
		strike();
	}
	
	public void step(){
		timer--;
		if (timer <= 0)
			strike();
	}
	
	public void render(){
		
	}
	
	private void strike(){
		sound.setSpeed(null, .5 + Calc.random(1.5));
		sound.play();
		timer = 2 + (int)Calc.random(wait);
		strikes--;
		if (strikes <= 0)
			destroy();
	}

}
